﻿using System;

namespace TryCancer
{
    class neurone
    {
        public double[] poids;
        public double output;
        int nb_entree;
        public static Random generator = new Random();
        public neurone(int _nb_entree)
        {
            output = Double.NaN;

            nb_entree = _nb_entree;
            poids = new double[nb_entree + 1];
            for (int i = 0; i < (nb_entree + 1); i++)
            {
                poids[i] = generator.NextDouble();
            }
        }



        public void Clear(){
            output = Double.NaN;
        }



        
        public double evaluate(double[] _entree)
        {

            if (Double.IsNaN(output))
            {
                double x = 0.0;
                for (int i = 0; i < nb_entree; i++)
                {
                    x += _entree[i] * poids[i];
                }
                x += poids[nb_entree];
                output = 1.0 / (1.0 + Math.Exp(-1.0 * x));
            }
            return output;
        }

    }
}
